local jijiu = fk.CreateSkill {

  name = "joyex__jijiu",

  tags = {  },

}



jijiu:addEffect("viewas", {
  name = "joyex__jijiu",
  anim_type = "support",
  pattern = "peach",
  card_filter = function(self, player, to_select, selected)
    if #selected == 1 then return false end
    return Fk:getCardById(to_select).color == Card.Red
  end,
  view_as = function(self, player,cards)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("peach")
    c.skillName = jijiu.name
    c:addSubcard(cards[1])
    return c
  end,
  after_use = function(self, player, use)
    local room = player.room
    local targets = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if p:getHandcardNum() > 0 then
        table.insert(targets,p.id)
      end
    end
      local target = room:askForChoosePlayers(player,targets,1,1,"#joy__jijiu-invoke",jijiu.name,true)
      if #target > 0 then
        local to = room:getPlayerById(target[1])
        local card = room:askForCardChosen(player,to,"h",jijiu.name)
        if card  then
          room:throwCard(card, jijiu.name, to, player)
        end
      end
  end,
  enabled_at_play = function(self, player)
    return false
  end,
  enabled_at_response = function(self, player)
    return player.phase == Player.NotActive
  end,
})

return jijiu